package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.BaseTrademark;
import com.atguigu.gmall.product.service.BaseTrademarkService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author Fxz
 * @version 1.0
 * @date 2022-02-05 17:46
 */
@SuppressWarnings("all")
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/product/baseTrademark")
public class BaseTrademarkController {

	private final BaseTrademarkService baseTrademarkService;

	/**
	 * 分页查询
	 */
	@GetMapping("{page}/{limit}")
	public Result<IPage<BaseTrademark>> getBaseTradeMarkList(@PathVariable("page") Long page,
			@PathVariable("limit") Long limit) {
		return Result.ok(baseTrademarkService.getBaseTradeMarkList(new Page<>(page, limit)));
	}

	@PostMapping("/save")
	public Result save(@RequestBody BaseTrademark baseTrademark) {
		baseTrademarkService.save(baseTrademark);
		return Result.ok();
	}

	@PutMapping("/update")
	public Result update(@RequestBody BaseTrademark baseTrademark) {
		return Result.ok(baseTrademarkService.updateById(baseTrademark));
	}

	@DeleteMapping("/remove/{id}")
	public Result remove(@PathVariable Long id) {
		return Result.ok(baseTrademarkService.removeById(id));
	}

	@GetMapping("/get/{id}")
	public Result getBaseTradeMarkList(@PathVariable Long id) {
		return Result.ok(baseTrademarkService.getById(id));
	}

	@GetMapping("/getTrademarkList")
	public Result getTrademarkList() {
		return Result.ok(baseTrademarkService.list());
	}

}
